from ronglian_sms_sdk import SmsSDK
from url.min import app
import redis,random

accId = '8aaf0708842397dd01843d9c63a808aa'
accToken = 'a44a4e4fab984dc39378789c36bf204b'
appId = '8aaf0708842397dd01843d9c648a08b1'

@app.task

def send_message(mobile):
    sdk = SmsSDK(appId,accToken,appId)
    tid = '1'
    data=random.randint(100000,999999)
    r=redis.Redis(host='127.0.0.1',port=6379,db=1)
    r.set(f'sms_code_{mobile}', data, ex=300)
    datas = (data)
    resp = sdk.sendMessage(tid, mobile, datas)
    print(resp)
    return resp